package net.sf.calibur.transport.message;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.InputStream;
import java.io.OutputStream;

public class SessionEstablishedMessage extends Message {
	private long establishTimestamp;
	private String sessionKey;
	
	public SessionEstablishedMessage() {
		super(Message.MT_SESSION_ESTABLISHED);
		this.establishTimestamp = System.currentTimeMillis();
	}

	public long getEstablishedTimestamp() {
		return establishTimestamp;
	}

	public void setEstablishTimestamp(long establishTimestamp) {
		this.establishTimestamp = establishTimestamp;
	}

	@Override
	public void serialize(OutputStream output) throws Exception {
		DataOutputStream dos = new DataOutputStream(output);
		dos.writeLong(establishTimestamp);
		dos.writeUTF(sessionKey);
	}

	@Override
	public void deserialize(InputStream input) throws Exception {
		DataInputStream dis = new DataInputStream(input);
		establishTimestamp = dis.readLong();
		sessionKey = dis.readUTF();
	}

	public String getSessionKey() {
		return sessionKey;
	}

	public void setSessionKey(String sessionKey) {
		this.sessionKey = sessionKey;
	}
}
